<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>创效统计</title>
  <style type="text/css">
  </style>
</head>
<body>
  <div class="layui-fluid">   
    <div class="layui-card">
      <!-- 查询区域  -->
      <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
        	<div class="layui-inline">
            	<label class="layui-form-label">统计年份</label>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_year_id"  name="year" readonly>
            	</div>
          	</div>
          	<div class="layui-inline">
            	<label class="layui-form-label">公司主体</label>
            	<div class="layui-input-inline" style="width:260px;">
              		<select name="orgTypeAndId" id="query_select_orgId" lay-filter="query_select_orgId" lay-search >
	              		<c:if test="${not empty orgInfos }">
	              			<c:forEach items="${orgInfos}" var="org">
	              				<option value="${org.id}-${org.types}" <c:if test="${org.id == bindOrgId }">selected</c:if>>${org.compName }</option>
		            		</c:forEach>
	              		</c:if>
	              	</select>
            	</div>
          	</div>
          	<div class="layui-inline">
            	<label class="layui-form-label">项目名称</label>
            	<div class="layui-input-inline">
              		<input type="text" name="proName" id="query_input_proName"  placeholder="请输入" autocomplete="off" class="layui-input" >
            	</div>
          	</div>
          	<shiro:hasPermission name="LIST_EFFECT_TOTAL">
	          <div class="layui-inline">
	            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-effectCollect-search">
	              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
	            </button>
	          </div>
          	</shiro:hasPermission>
        </div>
      </div>
      <div class="layui-card-body">
        <div style="text-align: center; margin-top:5px;  margin-bottom:18px;">
	          <div class="layui-inline" style="float:right;margin-bottom:2px;margin-right:0px;">
		         <label class="layui-form-label">单位：元</label> 
          	  </div>
        </div>
        <hr/>
        <table id="LAY-effectCollect-manage" lay-filter="LAY-effectCollect-manage"></table>
      </div>
    </div>
  </div>

  <script>
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set', 'laydate', 'element'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table
    	,laydate = layui.laydate
    	,element = layui.element;
	    
    	 laydate.render({
   	      elem: '#sts_year_id'
   	      ,type: 'year'
   	      ,btns: ['now', 'confirm']
   	      ,value: layui.util.toDateString(new Date(), 'yyyy') //当前年份
   	      ,done:function(value){
   	      	  table.reload('LAY-effectCollect-manage', {page: {curr: 1},
   			 	 where: {'year':value,'orgTypeAndId':$('#query_select_orgId').val(),'proName':$('#query_input_proName').val()}
   		      });
   	      }
   	    });
    	 
		form.on('select(query_select_orgId)', function(data){
   		 	table.reload('LAY-effectCollect-manage', {page: {curr: 1},
		 		where: {'year':$('#sts_year_id').val(),'orgTypeAndId':$('#query_select_orgId').val(),'proName':$('#query_input_proName').val()}
	      	});
    	});
		
    	// 表单
    	table.render({
      		elem: '#LAY-effectCollect-manage'
      		,url: basePath + '/effectSts/queryDataByCondition' //请求数据接口
      		,where: {'year':$('#sts_year_id').val(),'orgTypeAndId':$('#query_select_orgId').val(),'proName':$('#query_input_proName').val()}
      		,cols: [[
				{type:'numbers', title: '序号',fixed:'left', width: 80, align:'center', rowspan:2}
				,{field: 'orgAreaName', title: '区域公司',fixed:'left',width: 180, align:'center', rowspan:2}
				,{field: 'proName', title: '项目名称',fixed:'left',width: 280, align:'center', rowspan:2}
				,{title: '年度预算',width: 150, align:'center', rowspan:2, templet: function(d){
						var yearPlanAmount = 0;
						yearPlanAmount = d.monthPlanAmount1+d.monthPlanAmount2+d.monthPlanAmount3+d.monthPlanAmount4+d.monthPlanAmount5+d.monthPlanAmount6+d.monthPlanAmount7+d.monthPlanAmount8+d.monthPlanAmount9+d.monthPlanAmount10+d.monthPlanAmount11+d.monthPlanAmount12;
						return formatCurrency(yearPlanAmount);
					}
				}
				,{title: '年度完成',width: 150, align:'center', rowspan:2, templet: function(d){
						var yearSureAmount = 0;
						if(d.monthSureAmount1 != null && d.monthSureAmount1 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount1);
						}
						if(d.monthSureAmount2 != null && d.monthSureAmount2 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount2);
						}
						if(d.monthSureAmount3 != null && d.monthSureAmount3 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount3);
						}
						if(d.monthSureAmount4 != null && d.monthSureAmount4 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount4);
						}
						if(d.monthSureAmount5 != null && d.monthSureAmount5 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount5);
						}
						if(d.monthSureAmount6 != null && d.monthSureAmount6 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount6);
						}
						if(d.monthSureAmount7 != null && d.monthSureAmount7 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount7);
						}
						if(d.monthSureAmount8 != null && d.monthSureAmount8 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount8);
						}
						if(d.monthSureAmount9 != null && d.monthSureAmount9 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount9);
						}
						if(d.monthSureAmount10 != null && d.monthSureAmount10 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount10);
						}
						if(d.monthSureAmount11 != null && d.monthSureAmount11 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount11);
						}
						if(d.monthSureAmount12 != null && d.monthSureAmount12 != ''){
							yearSureAmount = yearSureAmount+parseFloat(d.monthSureAmount12);
						}
						return formatCurrency(yearSureAmount);
					}
				}
				,{title: '1季度', colspan:2, align:'center'}
				,{title: '2季度', colspan:2, align:'center'}
				,{title: '3季度', colspan:2, align:'center'}
				,{title: '4季度', colspan:2, align:'center'}
				,{title: '1月份', colspan:2, align:'center'}
				,{title: '2月份', colspan:2, align:'center'}
				,{title: '3月份', colspan:2, align:'center'}
				,{title: '4月份', colspan:2, align:'center'}
				,{title: '5月份', colspan:2, align:'center'}
				,{title: '6月份', colspan:2, align:'center'}
				,{title: '7月份', colspan:2, align:'center'}
				,{title: '8月份', colspan:2, align:'center'}
				,{title: '9月份', colspan:2, align:'center'}
				,{title: '10月份', colspan:2, align:'center'}
				,{title: '11月份', colspan:2, align:'center'}
				,{title: '12月份', colspan:2, align:'center'}
				],[
				{title: '预算',width: 150, align:'center', templet: function(d){
						var planAmount = 0;
						planAmount = d.monthPlanAmount1+d.monthPlanAmount2+d.monthPlanAmount3;
						return formatCurrency(planAmount);
					}
				}
				,{title: '完成',width: 150, align:'center', templet: function(d){
						var sureAmount = 0;
						if(d.monthSureAmount1 != null && d.monthSureAmount1 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount1);
						}
						if(d.monthSureAmount2 != null && d.monthSureAmount2 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount2);
						}
						if(d.monthSureAmount3 != null && d.monthSureAmount3 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount3);
						}
						return formatCurrency(sureAmount);
					}
				}
				,{title: '预算',width: 150, align:'center', templet: function(d){
						var planAmount = 0;
						planAmount = d.monthPlanAmount4+d.monthPlanAmount5+d.monthPlanAmount6;
						return formatCurrency(planAmount);
					}
				}
				,{title: '完成',width: 150, align:'center', templet: function(d){
						var sureAmount = 0;
						if(d.monthSureAmount4 != null && d.monthSureAmount4 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount4);
						}
						if(d.monthSureAmount5 != null && d.monthSureAmount5 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount5);
						}
						if(d.monthSureAmount6 != null && d.monthSureAmount6 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount6);
						}
						return formatCurrency(sureAmount);
					}
				}
				,{title: '预算',width: 150, align:'center', templet: function(d){
						var planAmount = 0;
						planAmount = d.monthPlanAmount7+d.monthPlanAmount8+d.monthPlanAmount9;
						return formatCurrency(planAmount);
					}
				}
				,{title: '完成',width: 150, align:'center', templet: function(d){
						var sureAmount = 0;
						if(d.monthSureAmount7 != null && d.monthSureAmount7 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount7);
						}
						if(d.monthSureAmount8 != null && d.monthSureAmount8 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount8);
						}
						if(d.monthSureAmount9 != null && d.monthSureAmount9 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount9);
						}
						return formatCurrency(sureAmount);
					}
				}
				,{title: '预算',width: 150, align:'center', templet: function(d){
						var planAmount = 0;
						planAmount = d.monthPlanAmount10+d.monthPlanAmount11+d.monthPlanAmount12;
						return formatCurrency(planAmount);
					}
				}
				,{title: '完成',width: 150, align:'center', templet: function(d){
						var sureAmount = 0;
						if(d.monthSureAmount10 != null && d.monthSureAmount10 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount10);
						}
						if(d.monthSureAmount11 != null && d.monthSureAmount11 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount11);
						}
						if(d.monthSureAmount12 != null && d.monthSureAmount12 != ''){
							sureAmount = sureAmount+parseFloat(d.monthSureAmount12);
						}
						return formatCurrency(sureAmount);
					}
				}
				,{field: 'monthPlanAmount1', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount1);
					}
				}
				,{field: 'monthSureAmount1', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount1 != null && d.monthSureAmount1 != ''){
							return formatCurrency(d.monthSureAmount1);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount2', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount2);
					}
				}
				,{field: 'monthSureAmount2', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount2 != null && d.monthSureAmount2 != ''){
							return formatCurrency(d.monthSureAmount2);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount3', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount3);
					}
				}
				,{field: 'monthSureAmount3', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount3 != null && d.monthSureAmount3 != ''){
							return formatCurrency(d.monthSureAmount3);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount4', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount4);
					}
				}
				,{field: 'monthSureAmount4', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount4 != null && d.monthSureAmount4 != ''){
							return formatCurrency(d.monthSureAmount4);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount5', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount5);
					}
				}
				,{field: 'monthSureAmount5', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount5 != null && d.monthSureAmount5 != ''){
							return formatCurrency(d.monthSureAmount5);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount6', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount6);
					}
				}
				,{field: 'monthSureAmount6', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount6 != null && d.monthSureAmount6 != ''){
							return formatCurrency(d.monthSureAmount6);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount7', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount7);
					}
				}
				,{field: 'monthSureAmount7', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount7 != null && d.monthSureAmount7 != ''){
							return formatCurrency(d.monthSureAmount7);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount8', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount8);
					}
				}
				,{field: 'monthSureAmount8', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount8 != null && d.monthSureAmount8 != ''){
							return formatCurrency(d.monthSureAmount8);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount9', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount9);
					}
				}
				,{field: 'monthSureAmount9', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount9 != null && d.monthSureAmount9 != ''){
							return formatCurrency(d.monthSureAmount9);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount10', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount10);
					}
				}
				,{field: 'monthSureAmount10', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount10 != null && d.monthSureAmount10 != ''){
							return formatCurrency(d.monthSureAmount10);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount11', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount11);
					}
				}
				,{field: 'monthSureAmount11', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount11 != null && d.monthSureAmount11 != ''){
							return formatCurrency(d.monthSureAmount11);
						}else{
							return global_null_tip;
						}
					}
				}
				,{field: 'monthPlanAmount12', title: '预算',width: 150, align:'center', templet: function(d){
						return formatCurrency(d.monthPlanAmount12);
					}
				}
				,{field: 'monthSureAmount12', title: '完成',width: 150, align:'center', templet: function(d){
						if(d.monthSureAmount12 != null && d.monthSureAmount12 != ''){
							return formatCurrency(d.monthSureAmount12);
						}else{
							return global_null_tip;
						}
					}
				}
				]]
      		,page: true
      		,limit: 10
    	});
    
    	<shiro:hasPermission name="LIST_EFFECT_TOTAL">
	    	//监听搜索
	    	form.on('submit(LAY-effectCollect-search)', function(data){
		      	//执行重载
		      	table.reload('LAY-effectCollect-manage', {page: {curr: 1},
		        	where: trimData(data)
		      	});
	    	});
    	</shiro:hasPermission>
  });
  	
  </script>
</body>
</html>

